
package de.fhhof.brst.event;

import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import de.fhhof.brst.dao.EventDAO;
import de.fhhof.brst.dao.HibernateEventDAO;
import de.fhhof.brst.data.Event;
@ManagedBean
@RequestScoped
public class CreateEvent implements Serializable {
  /**
   * 
   */
  private static final long serialVersionUID =  6659861099692255392L;

  private de.fhhof.brst.data.Event event;

  private de.fhhof.brst.dao.EventDAO eventDAO =  HibernateEventDAO.getHibernateEventDAO();

  public CreateEvent() {
		event = new Event();
  }

  public String submit() {
    	FacesMessage message = new FacesMessage("Event eingetragen!");

		eventDAO.createEvent(event);

        FacesContext.getCurrentInstance().addMessage(null, message);
        
        return "/events_frame.xhtml?faces-redirect=true";
  }

  public de.fhhof.brst.data.Event getEvent() {
		return event;
  }

  public void setEvent(de.fhhof.brst.data.Event event) {
		this.event = event;
  }

}
